<?php

class adminControl extends Control {

	public $user = null;

	public function __construct() {
		parent::__construct();
		// 增加登录判断,用户权限赋值
		$this->user = new backendUser($this->config->get_item('authorize'));
		
		if ( $this->user->is_login() == false) {
			$this->show_message("请先登录",  creat_url("",$this->config->get_item('site_url'),0,false));
			exit();
		}
	}

}

class backendUser {

	private $is_login = false;
	private $user_name = "游客";
	private $user_id = null;

	public function __construct($config) {
		$this->login();
	}

	public function login() {
		
		if(isset($_COOKIE['U'])) {
			$user_info = explode('|',authcode($_COOKIE['U'],'DECODE'));
			$authorize_model = &get_model('authorize');
			$result = $authorize_model->authorize($user_info["0"], $user_info["1"]);
			if ( $result === true && ($user_info = $authorize_model->get_user_info($user_info["0"])) ) {
				$this->is_login = true;
				$this->user_name = $user_info['nick_name'];
				$this->user_id = $result['user_id'];
			}
		}
	}

	public function login_out() {
		
	}

	public function is_login() {
		return $this->is_login;
	}

	public function get($item) {
		return isset($this->$item) ? $this->$item : false;
	}

}